package mainPackage;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * 
 */

/**
 * @author mfrehe
 *
 */
public class Dog implements iDog {
	
	SimpleDateFormat fmt = new SimpleDateFormat("dd.MM.yyyy");
	
	String dogName = null;
	Handler handler = null;
	String dogChipNumber = null;
	Calendar dogBirthday = new GregorianCalendar();
	Calendar dogRabbies = new GregorianCalendar();
	
	public Dog(String dogName, Handler handler, String dogChipNumber, Calendar dogBirthday, Calendar dogRabbies) {
		this.dogName = dogName;
		this.handler = handler;
		this.dogChipNumber = dogChipNumber;
		this.dogBirthday = dogBirthday;
		this.dogRabbies = dogRabbies;
		handler.addDog(this);
	}
	
	public Dog() {
		
	}

	
	@Override
	public String getName() {
		return this.dogName;
	}


	@Override
	public String getChipNumber() {
		return this.dogChipNumber;
	}
	
	@Override
	public Calendar getBirthday() {
		return this.dogBirthday;
	}
	
	@Override
	public Calendar getRabbies() {
		return this.dogRabbies;
	}
	
	@Override
	public Boolean checkRabbies() {
		
		Calendar today = Calendar.getInstance();
		
		today.set(Calendar.HOUR_OF_DAY, 0);
		today.set(Calendar.MINUTE, 0);
		today.set(Calendar.SECOND, 0);
		today.set(Calendar.MILLISECOND, 0);
		
		if(this.dogRabbies.getTimeInMillis() < today.getTimeInMillis()) {
			return false;
		}
		else {
			return true;
		}
	}
	
	public String toString() {
		String dateOfBirthFormatted = fmt.format(this.dogBirthday.getTime());
		return this.dogName + "\t" + this.dogChipNumber + "\t" + dateOfBirthFormatted + "\t" + this.checkRabbies();
	}
}
